Skip to content

feat(badge): port pf-v5-badge to pf-v6-badge element#3138

Open
zeroedin wants to merge 9 commits into
staging/pfv6from
feat/v6-badge
Open

feat(badge): port pf-v5-badge to pf-v6-badge element#3138
zeroedin wants to merge 9 commits into
staging/pfv6from
feat/v6-badge

Conversation

@zeroedin
Copy link
Copy Markdown
Collaborator

@zeroedin zeroedin commented May 8, 2026

Summary

  • Removes <pf-v5-badges>
  • Ports <pf-v5-badges> to <pf-v6-badge> web component for PatternFly v6
  • Displays numeric values with read/unread styling via light DOM text content
  • Supports threshold attribute to cap displayed value (e.g., "999+")
  • number attribute for programmatic value setting
  • disabled attribute dims the badge
  • Demos: basic (index), read, unread, disabled, threshold

Closes #2982
Depends on #3130

Intentional divergences from React

  • Uses light DOM text content instead of React's children prop for the numeric value
  • number and threshold attributes are not reflected (no CSS selectors use them)
  • disabled uses aria-disabled via ElementInternals rather than a host attribute

Test plan

  • npm run test passes
  • Demos render correctly at localhost:8000 with ?rendering=chromeless
  • Read/unread badge styling matches patternfly.org
  • Threshold displays "999+" when value exceeds threshold
  • Disabled badge is visually dimmed

Assisted-By: Claude noreply@anthropic.com

zeroedin added 4 commits May 8, 2026 14:06
Port pf-v5-badge to pf-v6-badge with v6 design tokens, CSS, and
API parity with PatternFly v6 React Badge component.

Changes from v5:
- Updated CSS custom properties to --pf-v6-c-badge--* namespace
- Added border overlay via ::after pseudo-element (new in v6)
- Added disabled state with pointer-events: none
- Switched to CSS logical properties (padding-inline-start/end)
- Simplified render: no wrapper span, slot for default content
- Added `@cssprop` JSDoc for all public CSS custom properties
- Added `@summary` and `@slot` JSDoc annotations
- Exported BadgeState type union

Demos match patternfly.org: read, unread, disabled, plus
WC-specific threshold demo.

Tests cover: instantiation, number/threshold display, state colors,
disabled styling, accessibility tree, slot content.

Closes #2982

Assisted-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove reflect from number and threshold properties (no CSS selectors)
- Fix threshold comparison: use <= instead of < so number=threshold shows +
- Simplify render return type to TemplateResult
- Add cem generate output path to config

Assisted-By: Claude Opus 4.6 <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 8, 2026

🦋 Changeset detected

Latest commit: 54dd0e8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@patternfly/elements Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

✅ Commitlint tests passed!

More Info
{
  "valid": true,
  "errors": [],
  "warnings": [],
  "input": "feat(badge): port pf-v5-badge to pf-v6-badge element"
}

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

Deploy Preview for patternfly-elements ready!

Name Link
🔨 Latest commit 3a09aee
😎 Deploy Preview https://deploy-preview-3138--patternfly-elements.netlify.app/

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions github-actions Bot added the AT passed Automated testing has passed label May 8, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

SSR Test Run for ac95104: Report

Copy link
Copy Markdown
Member

@bennypowers bennypowers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comments on the other 2 prs

Comment thread elements/pf-v6-badge/pf-v6-badge.ts Outdated
Copy link
Copy Markdown
Member

@bennypowers bennypowers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should remove all existing pf-v5-badge references

@github-actions
Copy link
Copy Markdown
Contributor

SSR Test Run for 3a09aee: Report

@zeroedin zeroedin changed the title feat(badge): add pf-v6-badge element feat(badge): port pf-v5-badge to pf-v6-badge element May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AT passed Automated testing has passed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants